<?php
require './mysqlConnect.php';
if($_SERVER['REQUEST_METHOD']=='GET'){
    $sql = "select * from fenxiang order by datetime desc limit 0,6";
    $res = $mysqli->query($sql);
    while($row=$res->fetch_assoc()){
    $lifeShareInfo[] =$row; 
    }
    echo json_encode($lifeShareInfo);
}else if($_SERVER['REQUEST_METHOD']=='POST'){
    $pageNum = $_POST['num'];
    $listNum = 3;
    $sql = "select * from fenxiang limit ".$pageNum*$listNum.",".($pageNum+1)*$listNum;
    $res = $mysqli->query($sql);
    while($row = $res->fetch_assoc()){
        $lifeListInfo[] = $row;
    } 
    $getCountSql = "select count(*) from fenxiang";
    $countRes = $mysqli->query($getCountSql);
    while($countRow = $countRes->fetch_assoc()){
         $sumNum = $countRow;
    }
    // echo implode($sumNum);
    array_push($lifeListInfo,implode($sumNum)/$listNum);
    echo json_encode($lifeListInfo);
}
?>